<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>v-on</title>
        <script type="text/javascript" src="../assets/js/vue.js"></script>
	</head>
	<body>
        <!-- 积分器 -->
        <h1>v-on</h1>
        <div id="app">
            本场得分：{{score}}
            <hr >
            <button type="button" v-on:click="addSco">加一分</button>
            <button type="button" v-on:click="subtract">减一分</button>
            <br>
            <input type="text" v-on:keyup.enter="onEnter()" v-model="inputScore"/>
        </div>
        
        <script type="text/javascript">
            
            var app = new Vue({
                el:'#app',
                data:{
                    score:0,
                    inputScore:1
                },
                methods:{
                    addSco:function(){
                        return this.score++;
                    },
                    subtract:function(){
                        return this.score--;
                    },
                    onEnter:function(){
                        this.score=this.score + parseInt(this.inputScore);
                    }
                }
            })
            
        </script>
	</body>
</html>
